﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VEXREDUS_GS_control
{
    public partial class Form5_GS_FBW : Form
    {
        int gsfbw_desired_attitude_updown = 0;
        int gsfbw_desired_attitude_leftright = 0;
        
        public Form5_GS_FBW()
        {
            InitializeComponent();
            
        }

        private void bt_gsfbw_up_Click(object sender, EventArgs e)
        {
            gsfbw_desired_attitude_updown += 3;
            string no_chksum = "$U" + gsfbw_desired_attitude_updown;
            string gsfbw_udpsendstring = no_chksum + "*" + Form1.calculate_checksum(no_chksum);
            Form1.UdpSend(gsfbw_udpsendstring);
            lb_gsfbw_desired_attitude_updown.Text = Convert.ToString(gsfbw_desired_attitude_updown);
            if (GlobalVar.current_fpcase == 5) tb_gsfbw_active.BackColor = Color.LimeGreen;
            else tb_gsfbw_active.BackColor = Color.Red;
        }

        private void bt_gsfbw_down_Click(object sender, EventArgs e)
        {
            gsfbw_desired_attitude_updown -= 3;
            string no_chksum = "$U" + gsfbw_desired_attitude_updown;
            string gsfbw_udpsendstring = no_chksum + "*" + Form1.calculate_checksum(no_chksum);
            Form1.UdpSend(gsfbw_udpsendstring);
            lb_gsfbw_desired_attitude_updown.Text = Convert.ToString(gsfbw_desired_attitude_updown);
        }

        private void bt_gsfbw_left_Click(object sender, EventArgs e)
        {
            gsfbw_desired_attitude_leftright -= 2;
            string no_chksum = "$L" + gsfbw_desired_attitude_leftright;
            string gsfbw_udpsendstring = no_chksum + "*" + Form1.calculate_checksum(no_chksum);
            Form1.UdpSend(gsfbw_udpsendstring);
            lb_gsfbw_desired_attitude_leftright.Text = Convert.ToString(gsfbw_desired_attitude_leftright);
        }

        private void bt_gsfbw_right_Click(object sender, EventArgs e)
        {
            gsfbw_desired_attitude_leftright += 2;
            string no_chksum = "$L" + gsfbw_desired_attitude_leftright;
            string gsfbw_udpsendstring = no_chksum + "*" + Form1.calculate_checksum(no_chksum);
            Form1.UdpSend(gsfbw_udpsendstring);
            lb_gsfbw_desired_attitude_leftright.Text = Convert.ToString(gsfbw_desired_attitude_leftright);
        }

        private void bt_gsfbw_middle_Click(object sender, EventArgs e)
        {
            gsfbw_desired_attitude_leftright = 0;
            string no_chksum = "$U" + gsfbw_desired_attitude_leftright;
            string gsfbw_udpsendstring = no_chksum + "*" + Form1.calculate_checksum(no_chksum);
            Form1.UdpSend(gsfbw_udpsendstring);
            lb_gsfbw_desired_attitude_leftright.Text = Convert.ToString(gsfbw_desired_attitude_leftright);
            
            System.Threading.Thread.Sleep(200);

            gsfbw_desired_attitude_updown = 0;
            no_chksum = "$L" + gsfbw_desired_attitude_updown;
            gsfbw_udpsendstring = no_chksum + "*" + Form1.calculate_checksum(no_chksum);
            Form1.UdpSend(gsfbw_udpsendstring);
            lb_gsfbw_desired_attitude_updown.Text = Convert.ToString(gsfbw_desired_attitude_updown);

        }

        
    }
}
